// 获取应用实例
const app = getApp()

Page({
	data: {
		img_src:app.globalData.img_src,
		popInviteshow: false,
		popShareshow: false,
		jinzhishow:false,
		userinfo:null,
		fansinfo:null
	},
	inviteBtn:function(){
		this.setData({
			popInviteshow:true
		})
	},
	onLoad(){
		var userinfo = wx.getStorageSync('memberinfo')
		this.setData({
			userinfo:userinfo
		})
		console.log(userinfo);
		if(userinfo.member_level !="帝王黑卡"){
			wx.redirectTo({
				url: '/pages/index/index'
			})	
		}
		
		if(userinfo.fans){
			this.setData({
				popInviteshow:true
			})
		}

		
	},
	onShow(){
		var userinfo = wx.getStorageSync('memberinfo')
		this.getinfo(userinfo.openid)
		if(userinfo.fans){
			this.setData({
				popInviteshow:true
			})
		}
	},
	getinfo(uid){
		console.log(uid);
		var that = this
		wx.request({
			url: app.globalData.apiurl+'access.php?a=userInfo', 
			header: {
				"Content-Type": "application/x-www-form-urlencoded"
			},
			data: {
				openid:uid
			},
			dataType:"json",
			method:"POST",
			success (res) {
				console.log(res);
					if(res.data.status == 1){
						
						that.setData({
							userinfo:res.data.data
						})
						
					}
			}
		})
	},
	onShareAppMessage() {
		var userinfo = this.data.userinfo;
		return {
			title: '2022法国娇兰VIP高端会员盛典',
			imageUrl:app.globalData.img_src+'share.jpg',
      path: '/pages/join/join?uid='+userinfo.openid,
    }
    
    // const promise = new Promise(resolve => {
    //   setTimeout(() => {
    //     resolve({
    //       title: '2022法国娇兰VIP高端会员盛典'
    //     })
    //   }, 2000)
		// })
		// console.log(userinfo)
    // return {
    //   title: '2022法国娇兰VIP高端会员盛典',
    //   path: '/pages/join/join?uid=o9gNK41hfn8eucBGX2VxUSm9-3wQ',
    //   promise 
    // }
  },
	closeBtn:function(){
		this.setData({
			popInviteshow:false
		})
	},
	hasfans(){
			this.setData({
				popInviteshow:true
			})
	}
})
